<template>
  <div>
    <headcamp :back="$route.meta.back" :title="$route.meta.title"></headcamp>
    <div class="search">
      <input type="text" placeholder="请输入文本" />
      <!-- //综合排序 -->
      <div class="all">
        <div>综合排序</div>
        <div>销量</div>
        <div>
          价格
          <img src="public/icon/sort.png" alt="" />
        </div>
        <div>好评度</div>
        <div>店铺</div>
        <div>
          <img src="public/icon/filter.png" alt="" />
          筛选
        </div>
      </div>
    </div>

    <ul class="shop">
      <li v-for="(ele, index) in goods" :key="index" @click="gotoDesc(ele.id)">
        <div class="shopImg">
          <img :src="$pre + ele.img" alt="" />
        </div>
        <div class="shopRight">
          <h5>{{ ele.goodsname }}</h5>
          <div class="market">
            <h4>￥{{ ele.market_price }}</h4>
            <p>￥{{ ele.price }}</p>
          </div>
          <div class="xz">双11.11限制</div>
          <div></div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      cateid: "", //商品分类的id
      page: 1, //页码
      size: 5, //每页几条
      type: "", //分类类型
      goods: [],
    };
  },
  methods: {
    fn() {
      let { cateid, page, size, type } = this;
      this.$api.goodList({ cateid, page, size, type }).then((res) => {
        this.goods = res.data.list.goodData;
      });
    },

    gotoDesc(id) {
      this.$router.push("goodDesc?id=" + id);
    },
  },
  created() {},
  mounted() {
    this.cateid = this.$route.query.cateid;

    this.type = this.$route.query.type;

    this.fn();
  },
  components: {},
  computed: {},
  watch: {},
};
</script>

<style lang='less' scoped>
.search {
  width: 100%;
  height: 140px;
  background-color: #ff6040;
  margin-top: 80px;

  input {
    font-size: 15px;
    width: 90%;
    height: 50px;
    border: 0;
    outline: 0;
    padding-left: 10px;
  }
}
.all {
  display: flex;
  font-size: 28px;
  padding: 0 20px;
  color: aliceblue;
  justify-content: space-between;
  margin-top: 20px;
}

.shop {
  li {
    display: flex;
    margin: 25px;
    .shopImg {
      width: 250px;
      height: 250px;
      img {
        width: 100%;
        height: 100%;
        border-radius: 20px;
      }
    }
    .shopRight {
      margin-left: 20px;
      font-size: 30px;
      h5 {
        font-weight: normal;
        padding-top: 15px;
      }
      .market {
        display: flex;
        margin-top: 15px;
        h4 {
          color: #d00;
        }
        p {
          color: #abaaac;
          text-decoration: line-through;
        }
      }
      .xz {
        padding: 5px 10px;
        background-color: #d00;
        font-size: 18px;
        margin-top: 15px;
        color: aliceblue;
      }
    }
  }
}
</style>
